package quickhit;

import java.util.Scanner;
/**
 * 游戏类
 */
public class Game {
    static Level[] levels = LevelParam.levels;      //定义一个新的数组接受静态数组
    public void player(){
          Scanner input = new Scanner(System.in);
            for (int i = 0; i <levels.length; i++) {       //等级
                int sum =0; //升级后积分清零
                for (int j = 0; j<levels[i].getCiShu() ; j++) {     //循环次数
                    long currentTime=System.currentTimeMillis();    //获取当前时间
                    StringBuffer buffer = new StringBuffer();       //字符串拼接
                    for (int a = 0; a <levels[i].getChang(); a++) {   //循环字符串
                        int rand = (int)(Math.random()*10);         //随机数
                        if (rand>5){
                            rand=rand-5;
                        }
                        switch (rand){
                            case 0:
                                buffer.append(".");
                                break;
                            case 1:
                                buffer.append(">");
                                break;
                            case 2:
                                buffer.append("<");
                                break;
                            case 3:
                                buffer.append("*");
                                break;
                            case 4:
                                buffer.append("-");
                                break;
                            case 5:
                                buffer.append("/");
                                break;
                        }
                        if (a==i+1){
                            System.out.print(buffer);
                        }
                    }
                    String m = buffer.toString();
                    System.out.println("请输入:");
                    String ziFu = input.next();     //用户输入
                    long newCurrentTime=(System.currentTimeMillis()-currentTime)/1000;
                    if (ziFu.equals(m)){
                        if (levels[i+1].getTime()>newCurrentTime){
                                sum+=levels[i].getScore();
                                System.out.println("等级是"+(i+1)+"级\t用时"+newCurrentTime+"秒"+
                                        "\t得分为:" +sum);
                        }else {
                            System.out.println("太慢了，退出程序");
                            return;
                        }
                    }else {
                        System.out.println("输入错误，退出程序");
                        return;
                    }
                }
            }
    }
}
